function BeClient() {
  this.defaultOptions = {
    preloaderShow: true,
    preloaderHide: true,
    timeout: 60000,
    async: true
  },
  this.handleException = function(response){
    if(response.exception !== null)
      APP.errorCallback(response.exception);
    if (response.callback !== null && response.callback !== undefined)
      return this.handleCallback(response.callback);
  },
  this.handleCallback = function(callback){
    switch(callback.action) {
      case 'redirect':
        Backbone.history.navigate(callback.target, {
          trigger: true
        });
        break;
      default:
    } 
  },
  this.onSuccess = function(data, options, method, callback) {
    if (options.preloaderHide)
      APP.hidePreloader();
    if (data.response.exception !== undefined)
      return this.handleException(data.response);
    if (data.response.responseStatus !== undefined){
      APP.User.setData(data.response.responseStatus.user);
      if (APP.User.get('forcePasswordChange') === true){
        new APP.Views.ChangePasswordView();
        return;
      }
    }

    if (callback != undefined){
      if (isFunction(callback))
        callback(data,options);
      else if (callback.obj !== undefined && callback.name !== undefined)
        callback.obj[callback.name](data.response, options);
    }
    var globalCallback = method + 'Success';
    if (this[globalCallback] !== undefined)
      this[globalCallback](data.response, options);
  },
  this.onError = function(data, callback, options) {
    if (callback != undefined){
      if (isFunction(callback))
        callback(data,options);
      else if (callback.obj !== undefined && callback.name !== undefined)
        callback.obj[callback.name](data, options);
    }
    noty({
      text        : UNDEFINED_ERROR_MESSAGE,
      type        : 'error',
      dismissQueue: true,
      layout      : 'top',
      theme       : 'defaultTheme'
    });
  },
  this.invoke = function (method, params, callbackSuccess, callbackError, options) {
    params.app = this.getApp();
    if (typeof options == "undefined")
      var options = {};
    options = $.extend({}, this.defaultOptions, options);
    var self = this;
    $.ajax({
      type: 'POST',
      url: ADDRESS_BE + method,
      cache: false,
      data: {
        'params': params
      },
      dataType: "json",
      async: options.async,  
      timeout: options.timeout,
      beforeSend: function () {
        if (options.preloaderShow)
          APP.showPreloader();
      },
      success: function(data) {
        self.onSuccess(data, options, method, callbackSuccess);
      },
      error: function(data, textStatus) {
        self.onError(data, callbackError, options);
      }
    });
  },
  this.login = function(email, password,  callbackSuccess, callbackError, options) {
    var u = new Object();
    u.email = email;
    u.password = password;
    this.invoke('login', u, callbackSuccess, callbackError, options);
  },
}